package com.example.fashion.android.util;

import android.content.Context;
import android.view.View;
import android.widget.Toast;

/**
 * Created by Faction on 2017/4/20.
 * Toast工具类
 */

public class ToastUtil {
    private static View view = null;
    private static Toast toast = null;
    private ToastUtil(){}

    public static ToastUtil getInstance(Context context){
        view = Toast.makeText(context,"",Toast.LENGTH_SHORT).getView();
        toast = new Toast(context);
        if(view != null){
            toast.setView(view);
        }
        return new ToastUtil();
    }

    /**
     * 显示要弹出的Toast内容
     * @param text
     */
    public void showToast(CharSequence text) {
        if(toast!=null){
            toast.setText(text);
            toast.setDuration(Toast.LENGTH_SHORT);
            toast.show();
        }
    }

    public void display(int Resid, int duration) {
        toast.setText(Resid);
        toast.setDuration(duration);
        toast.show();
    }
}
